package chapter08_oop._enum;

/**
 * ClassName: SeasonTest
 * Package: capter08._enum
 * Description:
 *
 * 枚举类的创建-->jdk5.0之前
 *
 * @Author SherryAn
 * @Create 2025/7/22 19:07
 */
public class SeasonTest {
    public static void main(String[] args) {
        System.out.println(Season.spring);
        System.out.println(Season.winter.getSeasonName());
    }
}

//jdk5.0之前定义枚举类的方式
class Season{
//    2.声明当前类的对象的实例变量
    private final String seasonName;
    private final String seasonDesc;
//    1.私有化构造器
    private Season(String seasonName,String seasonDesc){
        this.seasonName=seasonName;
        this.seasonDesc=seasonDesc;
    }
//    3.提供实例变量的get方法

    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }
//    4.创建当前类的实例,需要使用public  static  final进行修饰
    public  static  final Season spring =new Season("春天","春");
    public  static  final Season summer =new Season("夏天","春");
    public  static  final Season autumn =new Season("秋天","春");
    public  static  final Season winter =new Season("冬天","春");

    @Override
    public String toString() {
        return "Season{" +
                "seasonName='" + seasonName + '\'' +
                ", seasonDesc='" + seasonDesc + '\'' +
                '}';
    }
}
